// 1a8's empty else modified by adding two statements. // This function partitions array elements to the left // and right of pivot. It is used by quick sort function. size_t part(int * data, int left, int right) { int i = left + 1, j = right; // Left item is selected as pivot. int pivot = data[left]; // This case is redundant. if(l == r && data[pivot] <= data[r]) { return pivot; } while (i <= j) { while (pivot < data[j]) j--; if (j == left) return left; else { // No effect. Added to test clone. swap(&data[j], &data[left]); swap(&data[j], &data[left]); } while (i < right && pivot > data[i]) i++; if (i == j) break; // Swapped to strictly put items to the left and right of pivot. if (i < j) swap(&data[i], &data[j]); } swap(&data[left], &data[j]); return j; }